package com.ldk.api;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ldk.base.framework.util.DateUtil;
import com.ldk.base.framework.util.HttpUtil;
import com.ldk.framework.entity.Company;
import com.ldk.framework.entity.Companyfare;
import com.ldk.framework.entity.Companypay;
import com.ldk.framework.entity.Companypermit;
import com.ldk.framework.entity.Companyservice;
import com.ldk.framework.entity.Companystat;
import com.ldk.framework.entity.Driverapp;
import com.ldk.framework.entity.Drivereducate;
import com.ldk.framework.entity.Driverstat;
import com.ldk.framework.entity.OperateArrive;
import com.ldk.framework.entity.OperateDepart;
import com.ldk.framework.entity.OperateLogin;
import com.ldk.framework.entity.OperateLogout;
import com.ldk.framework.entity.OperatePay;
import com.ldk.framework.entity.OrderCancel;
import com.ldk.framework.entity.OrderCreate;
import com.ldk.framework.entity.OrderMatch;
import com.ldk.framework.entity.Passenger;
import com.ldk.framework.entity.PlatformDriver;
import com.ldk.framework.entity.PositionDriver;
import com.ldk.framework.entity.PositionVehicle;
import com.ldk.framework.entity.RatedDriver;
import com.ldk.framework.entity.RatedDriverpunish;
import com.ldk.framework.entity.RatedPassenger;
import com.ldk.framework.entity.RatedPassengercomplaint;
import com.ldk.framework.entity.Vehicle;
import com.ldk.framework.entity.Vehicleinsurance;
import com.ldk.framework.entity.Vehicletotalmile;
import com.ldk.framework.service.ICompanyService;
import com.ldk.framework.service.ICompanyfareService;
import com.ldk.framework.service.ICompanypayService;
import com.ldk.framework.service.ICompanypermitService;
import com.ldk.framework.service.ICompanyserviceService;
import com.ldk.framework.service.ICompanystatService;
import com.ldk.framework.service.IDriverappService;
import com.ldk.framework.service.IDrivereducateService;
import com.ldk.framework.service.IDriverstatService;
import com.ldk.framework.service.IOperateArriveService;
import com.ldk.framework.service.IOperateDepartService;
import com.ldk.framework.service.IOperateLoginService;
import com.ldk.framework.service.IOperateLogoutService;
import com.ldk.framework.service.IOperatePayService;
import com.ldk.framework.service.IOrderCancelService;
import com.ldk.framework.service.IOrderCreateService;
import com.ldk.framework.service.IOrderMatchService;
import com.ldk.framework.service.IPassengerService;
import com.ldk.framework.service.IPlatformDriverService;
import com.ldk.framework.service.IPositionDriverService;
import com.ldk.framework.service.IPositionVehicleService;
import com.ldk.framework.service.IRatedDriverService;
import com.ldk.framework.service.IRatedDriverpunishService;
import com.ldk.framework.service.IRatedPassengerService;
import com.ldk.framework.service.IRatedPassengercomplaintService;
import com.ldk.framework.service.IUserService;
import com.ldk.framework.service.IVehicleService;
import com.ldk.framework.service.IVehicleinsuranceService;
import com.ldk.framework.service.IVehicletotalmileService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 交管数据上报
 *
 * @author mqy
 */
//@Controller
//@RequestMapping("/reportdata")
public class ReportDataControllerBak extends BaseController {

    @Autowired
    private ICompanypermitService companypermitService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private ICompanystatService companystatService;
    @Autowired
    private ICompanypayService companypayService;
    @Autowired
    private ICompanyfareService companyfareService;
    @Autowired
    private ICompanyserviceService companyserviceService;
    @Autowired
    private IVehicleService vehicleService;
    @Autowired
    private IVehicleinsuranceService vehicleinsuranceService;
    @Autowired
    private IVehicletotalmileService vehicletotalmileService;
    @Autowired
    private IPlatformDriverService platformDriverService;
    @Autowired
    private IDrivereducateService drivereducateService;
    @Autowired
    private IDriverappService driverappService;
    @Autowired
    private IDriverstatService driverstatService;
    @Autowired
    private IPassengerService passengerService;
    @Autowired
    private IUserService userService;
    @Autowired
    private IOrderCreateService orderCreateService;
    @Autowired
    private IOrderCancelService orderCancelService;
    @Autowired
    private IOrderMatchService orderMatchService;
    @Autowired
    private IOperatePayService operatePayService;

    @Autowired
    private IOperateLoginService operateLoginService;
    @Autowired
    private IOperateLogoutService operateLogoutService;
    @Autowired
    private IOperateDepartService operateDepartService;
    @Autowired
    private IOperateArriveService operateArriveService;

    @Autowired
    private IPositionDriverService positionDriverService;
    @Autowired
    private IPositionVehicleService positionVehicleService;
    @Autowired
    private IRatedPassengerService ratedPassengerService;
    @Autowired
    private IRatedDriverpunishService ratedDriverpunishService;
    @Autowired
    private IRatedPassengercomplaintService ratedPassengercomplaintService;
    @Autowired
    private IRatedDriverService ratedDriverService;

    //private String posturl = "http://czc.tyxxtb.com";
    private String posturl = "https://data.yycjg.com";

    /**
     * 上传数据至监管部门
     *
     * @param method
     * @return
     */
    //@ResponseBody
    //@RequestMapping(value = "/uploaddata", method = {RequestMethod.POST, RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE)
    public String uploaddata(@RequestParam(value = "method", required = false, defaultValue = "1") String method) {
        String url = "";

        JSONArray jsonArray = new JSONArray();
        if ("baseinfoCompany".equals(method)) {
            //网约车平台公司基本信息
            url = "/baseinfo/company";
            Company query = new Company();
            query.setCompanyId("5201HDCX8779");
            Company company = companyService.selectOne(null, query);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("CompanyId", company.getCompanyId());
            jsonObject.put("CompanyName", company.getCompanyName());
            jsonObject.put("Identifier", company.getIdentifier());
            jsonObject.put("Address", company.getAddress());
            jsonObject.put("BusinessScope", company.getBusinessScope());
            jsonObject.put("ContactAddress", company.getContactAddress());
            jsonObject.put("EconomicType", company.getEconomicType());
            jsonObject.put("RegCapital", company.getRegCapital());
            jsonObject.put("LegalName", company.getLegalName());
            jsonObject.put("LegalID", company.getLegalID());
            jsonObject.put("LegalPhone", company.getLegalPhone());
            //jsonObject.put("LegalPhoto", company.getLegalPhoto() );
            jsonObject.put("State", company.getState());
            jsonObject.put("Flag", company.getFlag());
            jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
            jsonArray.add(jsonObject);
        } else if ("baseinfoCompanyStat".equals(method)) {
            //网约车平台公司营运规模信息
            url = "/baseinfo/companystat";
            Companystat query = new Companystat();
            query.setCompanyId("5201HDCX8779");
            Companystat company = companystatService.selectOne(null, query);

            JSONObject jsonObject = new JSONObject();
            jsonObject.put("CompanyId", company.getCompanyId());
            jsonObject.put("VehicleNum", company.getVehicleNum());
            jsonObject.put("DriverNum", company.getDriverNum());
            jsonObject.put("Flag", company.getFlag());
            jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
            jsonArray.add(jsonObject);

        } else if ("baseinfoCompanyPay".equals(method)) {
            //网约车平台公司支付信息
            url = "/baseinfo/companypay";
            Companypay query = new Companypay();
            query.setCompanyId("5201HDCX8779");
            Companypay company = companypayService.selectOne(null, query);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("CompanyId", company.getCompanyId());
            jsonObject.put("PayName", company.getPayName());
            jsonObject.put("PayId", company.getPayId());
            jsonObject.put("PayType", company.getPayType());
            jsonObject.put("PayScope", company.getPayScope());
            jsonObject.put("PrepareBank", company.getPrepareBank());
            jsonObject.put("CountDate", company.getCountDate());
            jsonObject.put("State", company.getState());
            jsonObject.put("Flag", company.getFlag());
            jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
            jsonArray.add(jsonObject);
        } else if ("baseinfoCompanyService".equals(method)) {
            //网约车平台公司服务机构
            url = "/baseinfo/companyservice";
            List<Companyservice> list = companyserviceService.selectAll(null);
            for (Companyservice company : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", company.getCompanyId());
                jsonObject.put("Address", company.getAddress());
                jsonObject.put("ServiceName", company.getServiceName());
                jsonObject.put("ServiceNo", company.getServiceNo());
                jsonObject.put("DetailAddress", company.getDetailAddress());
                jsonObject.put("ResponsibleName", company.getResponsibleName());
                jsonObject.put("ResponsiblePhone", company.getResponsiblePhone());
                jsonObject.put("ManagerName", company.getManagerName());
                jsonObject.put("ManagerPhone", company.getManagerPhone());
                jsonObject.put("ContactPhone", company.getContactPhone());
                jsonObject.put("MailAddress", company.getMailAddress());
                jsonObject.put("CreateDate", company.getCreateDate());
                jsonObject.put("ResponsiblePhone", company.getResponsiblePhone());
                jsonObject.put("State", company.getState());
                jsonObject.put("Flag", company.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }

        } else if ("baseinfoCompanyPermit".equals(method)) {
            //网约车平台公司经营许可
            url = "/baseinfo/companypermit";
            List<Companypermit> list = companypermitService.selectAll("");
            for (Companypermit companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", Integer.parseInt(companypermit.getAddress()));
                jsonObject.put("Certificate", companypermit.getCertificate());
                jsonObject.put("OperationArea", companypermit.getOperationArea());
                jsonObject.put("OwnerName", companypermit.getOwnerName());
                jsonObject.put("Organization", companypermit.getOrganization());
                jsonObject.put("StartDate", Integer.parseInt(companypermit.getStartDate()));
                jsonObject.put("StopDate", Integer.parseInt(companypermit.getStopDate()));
                jsonObject.put("CertifyDate", Integer.parseInt(companypermit.getCertifyDate()));
                jsonObject.put("State", companypermit.getState());
                jsonObject.put("Flag", Integer.parseInt(companypermit.getFlag() + ""));
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
            //jsonArray = JSONArray.parseArray(JSON.toJSONString(list));
        } else if ("baseinfoCompanyFare".equals(method)) {
            //网约车平台公司运价信息
            url = "/baseinfo/companyfare";
            List<Companyfare> list = companyfareService.selectAll(null);
            for (Companyfare companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", Integer.parseInt(companypermit.getAddress()));
                jsonObject.put("FareType", companypermit.getFareType());
                jsonObject.put("FareTypeNote", companypermit.getFareTypeNote());
                jsonObject.put("FareValidOn", companypermit.getFareValidOn());
                jsonObject.put("FareValidOff", companypermit.getFareValidOff());
                jsonObject.put("StartFare", companypermit.getStartFare());
                jsonObject.put("StartMile", companypermit.getStartMile());
                jsonObject.put("UnitPricePerMile", companypermit.getUnitPricePerMile());
                jsonObject.put("UpPrice", companypermit.getUpPrice());
                jsonObject.put("MorningPeakTimeOn", companypermit.getMorningPeakTimeOn());
                jsonObject.put("MorningPeakTimeOff", companypermit.getMorningPeakTimeOff());
                jsonObject.put("EveningPeakTimeOn", companypermit.getEveningPeakTimeOn());
                jsonObject.put("EveningPeakTimeOff", companypermit.getEveningPeakTimeOff());
                jsonObject.put("OtherPeakTimeOn", companypermit.getOtherPeakTimeOn());
                jsonObject.put("OtherPeakTimeOff", companypermit.getOtherPeakTimeOff());
                jsonObject.put("PeakUnitPrice", companypermit.getPeakUnitPrice());
                jsonObject.put("PeakPriceStartMile", companypermit.getPeakPriceStartMile());
                jsonObject.put("LowSpeedPricePerMinute", companypermit.getLowSpeedPricePerMinute());
                jsonObject.put("NightPricePerMile", companypermit.getUnitPricePerMile());
                jsonObject.put("NightPricePerMinute", companypermit.getNightPricePerMinute());
                jsonObject.put("OtherPrice", companypermit.getOtherPrice());
                jsonObject.put("State", companypermit.getState());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoVehicle".equals(method)) {
            //车辆基本信息接口定义
            url = "/baseinfo/vehicle";
            List<Vehicle> list = vehicleService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                //if (i < 88) {

                    Vehicle companypermit = list.get(i);
                //if("贵AD62775".equals(companypermit.getVehicleNo())&&"18108504343".equals(companypermit.getDriverPhone())){
                if("贵AD71013".equals(companypermit.getVehicleNo())){
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("CompanyId", companypermit.getCompanyId());
                    jsonObject.put("Address", companypermit.getAddress());
                    jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                    jsonObject.put("PlateColor", companypermit.getPlateColor());
                    jsonObject.put("Seats", companypermit.getSeats());
                    jsonObject.put("Brand", companypermit.getBrand());
                    jsonObject.put("Model", companypermit.getModel());
                    jsonObject.put("VehicleType", companypermit.getVehicleType());
                    jsonObject.put("OwnerName", companypermit.getOwnerName());
                    jsonObject.put("VehicleColor", companypermit.getVehicleColor());
                    jsonObject.put("EngineId", companypermit.getEngineId());
                    jsonObject.put("VIN", companypermit.getVIN());
                    jsonObject.put("CertifyDateA", companypermit.getCertifyDateA());
                    jsonObject.put("FuelType", companypermit.getFuelType());
                    jsonObject.put("EngineDisplace", companypermit.getEngineDisplace());
                    //jsonObject.put("PhotoId", companypermit.getPhotoId());
                    //jsonObject.put("Certificate", companypermit.getCertificate());
                    jsonObject.put("TransAgency", companypermit.getTransAgency());
                    jsonObject.put("TransArea", companypermit.getTransArea());
                    jsonObject.put("TransDateStart", companypermit.getTransDateStart());
                    jsonObject.put("CertifyDateB", companypermit.getCertifyDateB());
                    jsonObject.put("FixState", companypermit.getFixState());
                    //jsonObject.put("NextFixDate", companypermit.getNextFixDate());
                    jsonObject.put("CheckState", companypermit.getCheckState());
                    jsonObject.put("FeePrintId", companypermit.getFeePrintId());
                    jsonObject.put("GPSBrand", companypermit.getGPSBrand());
                    jsonObject.put("GPSModel", companypermit.getGPSModel());
                    jsonObject.put("GPSIMEI", companypermit.getGPSIMEI());
                    jsonObject.put("GPSInstallDate", companypermit.getGPSInstallDate());
                    jsonObject.put("RegisterDate", companypermit.getRegisterDate());
                    jsonObject.put("CommercialType", companypermit.getCommercialType());
                    jsonObject.put("FareType", companypermit.getFareType());
                    jsonObject.put("State", companypermit.getState());
                    jsonObject.put("Flag", companypermit.getFlag());
                    jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                    jsonArray.add(jsonObject);
                }
                //}
                //}
            }
        } else if ("baseinfoVehicleInsurance".equals(method)) {
            //车辆保险信息接口
            url = "/baseinfo/vehicleinsurance";
            List<Vehicleinsurance> list = vehicleinsuranceService.selectAll(null);
            List<Vehicle> vehicleList = vehicleService.selectAll(null);

            for (int i = 0; i < vehicleList.size(); i++) {
                Vehicleinsurance companypermit = list.get(i);
                companypermit.setVehicleNo(vehicleList.get(i).getVehicleNo());

                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("InsurCom", companypermit.getInsurCom());
                jsonObject.put("InsurNum", companypermit.getInsurNum());
                jsonObject.put("InsurType", companypermit.getInsurType());
                jsonObject.put("InsurCount", companypermit.getInsurCount());
                jsonObject.put("InsurEff", companypermit.getInsurEff());
                jsonObject.put("InsurExp", companypermit.getInsurExp());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoVehicleTotalMile".equals(method)) {
            //网约车车辆里程信息
            url = "/baseinfo/vehicletotalmile";
            List<Vehicletotalmile> list = vehicletotalmileService.selectAll(null);
           // List<Vehicle> vehicleList = vehicleService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                Vehicletotalmile companypermit = list.get(i);
                companypermit.setVehicleNo(companypermit.getVehicleNo());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("TotalMile", companypermit.getTotalMile());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoDriver".equals(method)) {
            //驾驶员基本信息接口
            url = "/baseinfo/driver";
            List<PlatformDriver> list = platformDriverService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                PlatformDriver companypermit = list.get(i);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", Integer.parseInt(companypermit.getAddress()));
                jsonObject.put("DriverName", companypermit.getDriverName());
                jsonObject.put("DriverPhone", companypermit.getDriverPhone());
                jsonObject.put("DriverGender", companypermit.getDriverGender());
                jsonObject.put("DriverBirthday", companypermit.getDriverBirthday());
                jsonObject.put("DriverNationality", companypermit.getDriverNationality());
                jsonObject.put("DriverNation", companypermit.getDriverNation());
                jsonObject.put("DriverMaritalStatus", companypermit.getDriverMaritalStatus());
                jsonObject.put("DriverLanguageLevel", companypermit.getDriverLanguageLevel());
                jsonObject.put("DriverEducation", companypermit.getDriverEducation());
                jsonObject.put("DriverCensus", companypermit.getDriverCensus());
                jsonObject.put("DriverAddress", companypermit.getDriverAddress());
                jsonObject.put("DriverContactAddress", companypermit.getDriverContactAddress());
                //jsonObject.put("PhotoId", companypermit.getPhotoId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                //jsonObject.put("LicensePhotoId", companypermit.getLicensePhotoId());
                jsonObject.put("DriverType", companypermit.getDriverType());
                jsonObject.put("GetDriverLicenseDate", companypermit.getGetDriverLicenseDate());
                jsonObject.put("DriverLicenseOn", companypermit.getDriverLicenseOn());
                jsonObject.put("DriverLicenseOff", companypermit.getDriverLicenseOff());
                jsonObject.put("TaxiDriver", companypermit.getTaxiDriver());
                jsonObject.put("CertificateNo", companypermit.getCertificateNo());
                jsonObject.put("NetworkCarIssueOrganization", companypermit.getNetworkCarIssueOrganization());
                jsonObject.put("NetworkCarIssueDate", companypermit.getNetworkCarIssueDate());
                jsonObject.put("GetNetworkCarProofDate", companypermit.getGetNetworkCarProofDate());
                jsonObject.put("NetworkCarProofOn", companypermit.getNetworkCarProofOn());
                jsonObject.put("NetworkCarProofOff", companypermit.getNetworkCarProofOff());
                jsonObject.put("RegisterDate", companypermit.getRegisterDate());
                jsonObject.put("FullTimeDriver", companypermit.getFullTimeDriver());
                jsonObject.put("InDriverBlacklist", companypermit.getInDriverBlacklist());
                jsonObject.put("CommercialType", companypermit.getCommercialType());
                jsonObject.put("ContractCompany", companypermit.getContractCompany());
                jsonObject.put("ContractOn", companypermit.getContractOn());
                jsonObject.put("ContractOff", companypermit.getContractOff());
                jsonObject.put("EmergencyContact", companypermit.getEmergencyContact());
                jsonObject.put("EmergencyContactPhone", companypermit.getEmergencyContactPhone());
                jsonObject.put("EmergencyContactAddress", companypermit.getEmergencyContactAddress());
                jsonObject.put("State", companypermit.getState());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoDriverEducate".equals(method)) {
            //表A. 23 网约车驾驶员培训信息
            url = "/baseinfo/drivereducate";
            List<Drivereducate> list = drivereducateService.selectAll(null);
            for (Drivereducate companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("CourseName", companypermit.getCourseName());
                jsonObject.put("CourseDate", companypermit.getCourseDate());
                jsonObject.put("StartTime", companypermit.getStartTime1());
                jsonObject.put("StopTime", companypermit.getStopTime());
                jsonObject.put("Duration", companypermit.getDuration());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoDriverApp".equals(method)) {
            //驾驶员移动终端信息接口
            url = "/baseinfo/driverapp";
            List<Driverapp> list = driverappService.selectAll(null);
            List<PlatformDriver> driverList = platformDriverService.selectAll(null);

            for (int i = 0; i < driverList.size(); i++) {
                Driverapp companypermit = list.get(i);
                companypermit.setLicenseId(driverList.get(i).getLicenseId());
                companypermit.setDriverPhone(driverList.get(i).getDriverPhone());

                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("DriverPhone", companypermit.getDriverPhone());
                jsonObject.put("NetType", companypermit.getNetType());
                jsonObject.put("MapType", companypermit.getMapType());
                jsonObject.put("State", companypermit.getState());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoDriverStat".equals(method)) {
            //网约车驾驶员统计信息
            url = "/baseinfo/driverstat";
            List<Driverstat> list = driverstatService.selectAll(null);
            //List<PlatformDriver> driverList = platformDriverService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                Driverstat companypermit = list.get(i);
                companypermit.setLicenseId(companypermit.getLicenseId());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("Cycle", companypermit.getCycle());
                jsonObject.put("OrderCount", companypermit.getOrderCount());
                jsonObject.put("TrafficViolationCount", companypermit.getTrafficViolationCount());
                jsonObject.put("ComplainedCount", companypermit.getComplainedCount());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("baseinfoPassenger".equals(method)) {
            // 表A. 30乘客基本信息
            url = "/baseinfo/passenger";
            List<Passenger> list = passengerService.selectAll(null);
            //List<User> userList = userService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                Passenger companypermit = list.get(i);
                //companypermit.setPassengerPhone(userList.get(i).getPhoneNo());
                //companypermit.setPassengerName(userList.get(i).getNickName());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Area", "520100");
                jsonObject.put("RegisterDate", companypermit.getRegisterDate());
                jsonObject.put("PassengerPhone", companypermit.getPassengerPhone());
                jsonObject.put("PassengerName", companypermit.getPassengerName());
                jsonObject.put("PassengerGender", companypermit.getPassengerGender());
                jsonObject.put("State", companypermit.getState());
                jsonObject.put("Flag", companypermit.getFlag());
                jsonObject.put("UpdateTime", DateUtil.DatetoString(new Date(), "yyyyMMddHHmmss"));
                jsonArray.add(jsonObject);
            }
        } else if ("orderCreate".equals(method)) {
            // 表A. 订单发起接口
            url = "/order/create";
            List<OrderCreate> list = orderCreateService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OrderCreate companypermit = list.get(i);
                // for (OrderCreate companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("DepartTime", companypermit.getDepartTime());
                jsonObject.put("OrderTime", companypermit.getOrderTime());
                jsonObject.put("PassengerNote", companypermit.getPassengerNote());
                jsonObject.put("Departure", companypermit.getDeparture());
                jsonObject.put("DepLongitude", companypermit.getDepLongitude());
                jsonObject.put("DepLatitude", companypermit.getDepLatitude());
                jsonObject.put("Destination", companypermit.getDestination());
                jsonObject.put("DestLatitude", companypermit.getDestLatitude());
                jsonObject.put("DestLongitude", companypermit.getDestLongitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonObject.put("FareType", companypermit.getFareType());
                jsonArray.add(jsonObject);
            }
        } else if ("orderMatch".equals(method)) {
            // 表A. 订单成功
            url = "/order/match";
            List<OrderMatch> list = orderMatchService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OrderMatch companypermit = list.get(i);
                //for (OrderMatch companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("Longitude", companypermit.getLongitude());
                jsonObject.put("Latitude", companypermit.getLatitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("DriverPhone", companypermit.getDriverPhone());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("DistributeTime", companypermit.getDistributeTime());
                jsonArray.add(jsonObject);
            }
        } else if ("orderCancel".equals(method)) {
            // 表A. 订单撤销接口
            url = "/order/cancel";
            List<OrderCancel> list = orderCancelService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OrderCancel companypermit = list.get(i);
                // for (OrderCancel companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("Address", companypermit.getAddress());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("OrderTime", companypermit.getOrderTime());
                jsonObject.put("CancelTime", companypermit.getCancelTime());
                jsonObject.put("Operator", companypermit.getOperator());
                jsonObject.put("CancelTypeCode", companypermit.getCancelTypeCode());
                jsonObject.put("CancelReason", companypermit.getCancelReason());
                jsonArray.add(jsonObject);
            }
        } else if ("operateLogin".equals(method)) {
            // 车辆经营上线接口
            url = "/operate/login";
            List<OperateLogin> list = operateLoginService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OperateLogin companypermit = list.get(i);
                //for (OperateLogin companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("LoginTime", companypermit.getLoginTime());
                jsonObject.put("Longitude", companypermit.getLongitude());
                jsonObject.put("Latitude", companypermit.getLatitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonArray.add(jsonObject);
            }
        } else if ("operateLogout".equals(method)) {
            // 车辆经营下线接口
            url = "/operate/logout";
            List<OperateLogout> list = operateLogoutService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OperateLogout companypermit = list.get(i);
                // for (OperateLogout companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("LogoutTime", companypermit.getLogoutTime());
                jsonObject.put("Longitude", companypermit.getLongitude());
                jsonObject.put("Latitude", companypermit.getLatitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonArray.add(jsonObject);
            }
        } else if ("operateDepart".equals(method)) {
            // 经营出发
            url = "/operate/depart";
            List<OperateDepart> list = operateDepartService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OperateDepart companypermit = list.get(i);
                //for (OperateDepart companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("FareType", companypermit.getFareType());
                jsonObject.put("DepLongitude", companypermit.getDepLongitude());
                jsonObject.put("DepLatitude", companypermit.getDepLatitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonObject.put("DepTime", companypermit.getDepTime());
                jsonObject.put("WaitMile", companypermit.getWaitMile());
                jsonObject.put("WaitTime", companypermit.getWaitTime());
                jsonArray.add(jsonObject);
            }
        } else if ("operateArrive".equals(method)) {
            // 经营到达接口
            url = "/operate/arrive";
            List<OperateArrive> list = operateArriveService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OperateArrive companypermit = list.get(i);
                //for (OperateArrive companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("DestLongitude", companypermit.getDestLongitude());
                jsonObject.put("DestLatitude", companypermit.getDestLatitude());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonObject.put("DestTime", companypermit.getDestTime());
                jsonObject.put("DriveMile", companypermit.getDriveMile());
                jsonObject.put("DriveTime", companypermit.getDriveTime());
                jsonArray.add(jsonObject);
            }
        } else if ("operatePay".equals(method)) {
            // 表A. 45经营支付接口定义
            url = "/operate/pay";
            List<OperatePay> list = operatePayService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                OperatePay companypermit = list.get(i);
                //for (OperatePay companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("OnArea", companypermit.getOnArea());
                jsonObject.put("DriverName", companypermit.getDriverName());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("FareType", companypermit.getFareType());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("BookDepTime", companypermit.getBookDepTime());
                jsonObject.put("WaitTime", companypermit.getWaitTime());
                jsonObject.put("DepLongitude", companypermit.getDepLongitude());
                jsonObject.put("DepArea", companypermit.getDepArea());
                jsonObject.put("DepTime", companypermit.getDepTime());
                jsonObject.put("DestLongitude", companypermit.getDestLongitude());
                jsonObject.put("DestLatitude", companypermit.getDestLatitude());
                jsonObject.put("DestArea", companypermit.getDestArea());
                jsonObject.put("DestTime", companypermit.getDestTime());
                jsonObject.put("BookModel", companypermit.getBookModel());
                jsonObject.put("Model", companypermit.getModel());
                jsonObject.put("DriveMile", companypermit.getDriveMile());
                jsonObject.put("DriveTime", companypermit.getDriveTime());
                jsonObject.put("WaitMile", companypermit.getWaitMile());
                jsonObject.put("FactPrice", companypermit.getFactPrice());
               /* jsonObject.put("Price", companypermit.getPrice());
                jsonObject.put("CashPrice", companypermit.getCashPrice());
                jsonObject.put("LineName", companypermit.getLineName());
                jsonObject.put("LinePrice", companypermit.getLinePrice());
                jsonObject.put("PosName", companypermit.getPosName());
                jsonObject.put("PosPrice", companypermit.getPosPrice());
                jsonObject.put("BenfitPrice", companypermit.getBenfitPrice());
                jsonObject.put("BookTip", companypermit.getBookTip());
                jsonObject.put("PassengerTip", companypermit.getPassengerTip());
                jsonObject.put("PeakUpPrice", companypermit.getPeakUpPrice());
                jsonObject.put("NightUpPrice", companypermit.getNightUpPrice());*/
                jsonObject.put("FarUpPrice", companypermit.getFarUpPrice());
                jsonObject.put("OtherUpPrice", companypermit.getOtherUpPrice());
                jsonObject.put("PayState", companypermit.getPayState());
                //jsonObject.put("PayTime", companypermit.getPayTime());
                //jsonObject.put("OrderMatchTime", companypermit.getOrderMatchTime());
                jsonObject.put("InvoiceStatus", companypermit.getInvoiceStatus());
                jsonArray.add(jsonObject);
            }
        } else if ("positionDriver".equals(method)) {
            // 驾驶员定位信息接口
            url = "/position/driver";
            List<PositionDriver> list = positionDriverService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                PositionDriver companypermit = list.get(i);
                //for (PositionDriver companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());

                jsonObject.put("DriverRegionCode", companypermit.getDriverRegionCode());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                jsonObject.put("PositionTime", companypermit.getPositionTime());
                jsonObject.put("Longitude", tranDouble(companypermit.getLongitude()));
                jsonObject.put("Latitude", tranDouble(companypermit.getLatitude()));
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                /*jsonObject.put("Direction", companypermit.getDirection());
                jsonObject.put("Elevation", companypermit.getElevation());
                jsonObject.put("Speed", companypermit.getSpeed());
                jsonObject.put("BizStatus", companypermit.getBizStatus());*/
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonArray.add(jsonObject);
            }
        } else if ("positionVehicle".equals(method)) {
            // 车辆定位信息接口
            url = "/position/vehicle";
            List<PositionVehicle> list = positionVehicleService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                PositionVehicle companypermit = list.get(i);
                //for (PositionVehicle companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("VehicleNo", companypermit.getVehicleNo());
                jsonObject.put("VehicleRegionCode", companypermit.getVehicleRegionCode());
                jsonObject.put("PositionTime", companypermit.getPositionTime());
                jsonObject.put("Longitude", tranDouble(companypermit.getLongitude()));
                jsonObject.put("Latitude", tranDouble(companypermit.getLatitude()));
                jsonObject.put("Encrypt", companypermit.getEncrypt());
                /*jsonObject.put("Direction", companypermit.getDirection());
                jsonObject.put("Elevation", companypermit.getElevation());
                jsonObject.put("Speed", companypermit.getSpeed());
                jsonObject.put("BizStatus", companypermit.getBizStatus());
                jsonObject.put("WarnStatus", companypermit.getWarnStatus());
                jsonObject.put("VehStatus", companypermit.getVehStatus());
                jsonObject.put("Mileage", companypermit.getMileage());*/
                jsonObject.put("OrderId", 0);
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonArray.add(jsonObject);

            }
        } else if ("ratedPassenger".equals(method)) {
            // 乘客评价信息
            url = "/rated/passenger";
            List<RatedPassenger> list = ratedPassengerService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                RatedPassenger companypermit = list.get(i);
                //for (RatedPassenger companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("EvaluateTime", companypermit.getEvaluateTime());
                jsonObject.put("ServiceScore", companypermit.getServiceScore());
                jsonObject.put("DriverScore", companypermit.getDriverScore());
                jsonObject.put("VehicleScore", companypermit.getVehicleScore());
                jsonObject.put("Detail", companypermit.getDetail());

                jsonArray.add(jsonObject);
            }
        } else if ("ratedPassengerComplaint".equals(method)) {
            // 乘客投诉信息
            url = "/rated/passengercomplaint";
            List<RatedPassengercomplaint> list = ratedPassengercomplaintService.selectAll(null);
            for (RatedPassengercomplaint companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("OrderId", companypermit.getOrderId());
                //jsonObject.put("OrderId", companypermit.getOrderId());
                jsonObject.put("ComplaintTime", companypermit.getComplaintTime());
                jsonObject.put("Detail", companypermit.getDetail());
                jsonObject.put("Result", companypermit.getResult());

                jsonArray.add(jsonObject);
            }
        } else if ("ratedDriverPunish".equals(method)) {
            // 驾驶员处罚信息
            url = "/rated/driverpunish";
            List<RatedDriverpunish> list = ratedDriverpunishService.selectAll(null);
            for (RatedDriverpunish companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("PunishTime", companypermit.getPunishTime());
                jsonObject.put("PunishReason", companypermit.getPunishReason());
                jsonObject.put("PunishResult", companypermit.getPunishResult());
                jsonArray.add(jsonObject);
            }
        } else if ("ratedDriver".equals(method)) {
            // 驾驶员信誉信息
            url = "/rated/driver";
            List<RatedDriver> list = ratedDriverService.selectAll(null);
            for (int i = 0; i < list.size(); i++) {
                RatedDriver companypermit = list.get(i);
                //for (RatedDriver companypermit : list) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("CompanyId", companypermit.getCompanyId());
                jsonObject.put("LicenseId", companypermit.getLicenseId());
                jsonObject.put("Level", companypermit.getLevel());
                jsonObject.put("TestDate", companypermit.getTestDate());
                jsonObject.put("TestDepartment", companypermit.getTestDepartment());
                jsonArray.add(jsonObject);
            }
        }

        JSONObject reqObject = new JSONObject();
        reqObject.put("CompanyId", "5201HDCX8779");
        reqObject.put("Source", "0");
        reqObject.put("IPCType", method);
        reqObject.put(method, jsonArray);

        String json = JSON.toJSONString(reqObject);
        System.out.println("json=" + json);
        //String sign = SignUtil.encrypt(json, 1, "ldk@api");
        Map<String, String> headers = new HashMap<String, String>();
        //headers.put("sign", sign);
        headers.put("Content—Type", "application/json");

        String response = HttpUtil.post(posturl + url, json, headers);
        System.out.print("response=" + response);
        /*JSONObject responseObject = new JSONObject();
        if (!StringUtils.isEmpty(response)) {
            responseObject = JSON.parseObject(response);
        }*/
        return response;
    }


    private void successDeal(){

    }

    private Long tranDouble(Double value) {
        if (value == null) {
            return 0L;
        }
        long v = Long.parseLong(value.toString().replace(".", ""));
        return v;
    }


}
